static void
gtk_file_chooser_default_init (GtkFileChooserInterface *iface)
{
- GType iface_type = G_TYPE_FROM_INTERFACE (iface);
-
- /**
- * GtkFileChooser::selection-changed:
- * @chooser: the object which received the signal.
- *
- * This signal is emitted when there is a change in the set of selected files
- * in a #GtkFileChooser. This can happen when the user modifies the selection
- * with the mouse or the keyboard, or when explicitly calling functions to
- * change the selection.
- *
- * Normally you do not need to connect to this signal, as it is easier to wait
- * for the file chooser to finish running, and then to get the list of
- * selected files using the functions mentioned below.
- */
- g_signal_new (I_("selection-changed"),
- iface_type,
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GtkFileChooserIface, selection_changed),
- NULL, NULL,
- NULL,
- G_TYPE_NONE, 0);
-
g_object_interface_install_property (iface,
g_param_spec_enum ("action",
P_("Action"),
if (button->is_changing_selection)
{
button->is_changing_selection = FALSE;
- g_signal_emit_by_name (button, "selection-changed");
}
}
response == GTK_RESPONSE_OK)
{
save_inactive_state (button);
-
- g_signal_emit_by_name (button, "selection-changed");
}
else
{
int baseline);
static void file_chooser_widget_response_requested (GtkWidget *widget,
GtkFileChooserDialog *dialog);
-static void file_chooser_widget_selection_changed (GtkWidget *widget,
- GtkFileChooserDialog *dialog);
static void response_cb (GtkDialog *dialog,
gint response_id);
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserDialog, buttons);
gtk_widget_class_bind_template_callback (widget_class, response_cb);
gtk_widget_class_bind_template_callback (widget_class, file_chooser_widget_response_requested);
- gtk_widget_class_bind_template_callback (widget_class, file_chooser_widget_selection_changed);
}
static void
response_id == GTK_RESPONSE_APPLY);
}
-static void
-file_chooser_widget_selection_changed (GtkWidget *widget,
- GtkFileChooserDialog *dialog)
-{
- GtkFileChooserDialogPrivate *priv = gtk_file_chooser_dialog_get_instance_private (dialog);
- GtkWidget *button;
- GListModel *files;
- gboolean sensitive;
-
- button = get_accept_action_widget (GTK_DIALOG (dialog), FALSE);
- if (button == NULL)
- return;
-
- files = gtk_file_chooser_get_files (GTK_FILE_CHOOSER (priv->widget));
- sensitive = (g_list_model_get_n_items (files) > 0);
- gtk_widget_set_sensitive (button, sensitive);
-
- g_object_unref (files);
-}
-
static void
file_chooser_widget_response_requested (GtkWidget *widget,
GtkFileChooserDialog *dialog)
* possible to use with #GtkFileChooserNative, as such use would
* prohibit the use of a native dialog.
*
- * There is no support for the signals that are emitted when the user
- * navigates in the dialog, including:
- * * #GtkFileChooser::selection-changed
- *
- * If you need any of the above you will have to use #GtkFileChooserDialog directly.
- *
* No operations that change the dialog work while the dialog is visible.
* Set all the properties that are required before showing the dialog.
*
static void delegate_notify (GObject *object,
GParamSpec *pspec,
gpointer data);
-static void delegate_selection_changed (GtkFileChooser *chooser,
- gpointer data);
static void delegate_add_choice (GtkFileChooser *chooser,
const char *id,
g_object_set_data (G_OBJECT (receiver), I_("gtk-file-chooser-delegate"), delegate);
g_signal_connect (delegate, "notify",
G_CALLBACK (delegate_notify), receiver);
- g_signal_connect (delegate, "selection-changed",
- G_CALLBACK (delegate_selection_changed), receiver);
}
GQuark
g_object_notify (data, pspec->name);
}
-static void
-delegate_selection_changed (GtkFileChooser *chooser,
- gpointer data)
-{
- g_signal_emit_by_name (data, "selection-changed");
-}
-
GSettings *
_gtk_file_chooser_get_settings_for_widget (GtkWidget *widget)
{
ypad * 2 + ICON_SIZE);
}
+static GtkWidget *
+get_accept_action_widget (GtkDialog *dialog,
+ gboolean sensitive_only)
+{
+ gint response[] = {
+ GTK_RESPONSE_ACCEPT,
+ GTK_RESPONSE_OK,
+ GTK_RESPONSE_YES,
+ GTK_RESPONSE_APPLY
+ };
+ gint i;
+ GtkWidget *widget;
+
+ for (i = 0; i < G_N_ELEMENTS (response); i++)
+ {
+ widget = gtk_dialog_get_widget_for_response (dialog, response[i]);
+ if (widget)
+ {
+ if (!sensitive_only)
+ return widget;
+
+ if (gtk_widget_is_sensitive (widget))
+ return widget;
+ }
+ }
+
+ return NULL;
+}
+
+static void
+update_default (GtkFileChooserWidget *impl)
+{
+ GtkWidget *dialog;
+ GtkWidget *button;
+ GListModel *files;
+ gboolean sensitive;
+
+ dialog = gtk_widget_get_ancestor (GTK_WIDGET (impl), GTK_TYPE_DIALOG);
+ if (dialog == NULL)
+ return;
+
+ button = get_accept_action_widget (GTK_DIALOG (dialog), FALSE);
+ if (button == NULL)
+ return;
+
+ files = gtk_file_chooser_get_files (GTK_FILE_CHOOSER (impl));
+ sensitive = (g_list_model_get_n_items (files) > 0);
+ gtk_widget_set_sensitive (button, sensitive);
+
+ g_object_unref (files);
+}
+
static gboolean
location_changed_timeout_cb (gpointer user_data)
{
GtkFileChooserWidget *impl = user_data;
gtk_file_chooser_unselect_all (GTK_FILE_CHOOSER (impl));
- g_signal_emit_by_name (impl, "selection-changed", 0);
+ update_default (impl);
impl->location_changed_id = 0;
return G_SOURCE_REMOVE;
g_object_notify (G_OBJECT (impl), "subtitle");
- g_signal_emit_by_name (impl, "selection-changed", 0);
+ update_default (impl);
out:
g_object_unref (data->impl);
update_chooser_entry (impl);
location_bar_update (impl);
-
- g_signal_emit_by_name (impl, "selection-changed", 0);
+ update_default (impl);
}
static gboolean
<property name="hexpand">1</property>
<property name="vexpand">1</property>
<signal name="response-requested" handler="file_chooser_widget_response_requested" swapped="no"/>
- <signal name="selection-changed" handler="file_chooser_widget_selection_changed" swapped="no"/>
</object>
</child>
</object>